<?php

namespace app\beautiful\model\appointment;

use app\beautiful\model\StaffModel;

use app\common\model\CommonModel;



class PerformanceModel extends CommonModel{

    protected  $name = 'beautiful_performance';

    protected  $pk   = 'performance_id';

    protected $type=[

        'pictures'=>'array',

    ];



    public function staff()

    {

        return $this->hasOne(StaffModel::class,'staff_id','staff_id');

    }



    public function items()

    {

        return $this->hasMany(PerformanceItemModel::class,'performance_id','performance_id');

    }



    public function getAddTimeDayFormatAttr($value,$data)

    {



        return $data['add_time'] > 0 ? date('Y-m-d',$data['add_time']) : '-';

    }



    public function getStatusMeansAttr($value,$data)

    {

        $status_means=[

            1=>'待核准',

            8=>'核准通过',

            -1=>'核准不过',

        ];

        return $status_means[$data['status']] ?? '-';

    }



}

